<?php
namespace app\indexLogin\common;

use think\Controller;
use think\Db;
use \think\Session;

class Common extends Controller{
     public  function  __construct(){
          parent::__construct();
          Session::set('uid',1);
          $uid=Session::get('uid');
          //获取当前用户名
          $username=Db::table('wb_user')
              ->where('uid','=',$uid)
              ->value('username');
          V('username',$username);

          // 调取添加关注用户的数据
//          已经关注的用户

          $focus=Db::table('wb_focus')->where('uid','=',$uid)->column('fid');
//          dd($focus);die;
          $users=Db::table('wb_user')
              ->whereNotIn('uid',$focus)
              ->limit(5)
              ->select();
          V('users',$users);
          //获取用户的粉丝数
          $fans=Db::table('wb_user')
              ->alias('u')
              ->join('wb_focus f','u.uid = f.uid')
              ->where('f.fid','=',$uid)
              ->count();
//         dd($fans);
//         $fans=empty($fans)?1:$fans;
          V('fans',$fans);

          //获取用户的关注数
          $focus=Db::table('wb_user')
              ->alias('u')
              ->join('wb_focus f','u.uid = f.uid')
              ->where('f.uid','=',$uid)
              ->count();
          V('focus',$focus);

//         获取微博数
          $counts=Db::table('wb_weibo')
              ->where('uid','=',$uid)
              ->count();
          V('counts',$counts);
     }

}